from aiogram import Router, types, F
from aiogram.filters import CommandStart
from datetime import datetime
import random

from classes.JsonDealer import JsonDealer
from classes.SubjectsTranslator import SubjectsTranslator

router = Router()

@router.message(CommandStart())
async def start(message: types.Message):
    data = JsonDealer.readData()
    if data == {}:
        text_subject = "чему-то"
        text_time = "сколько-то"
    else:
        subject = random.choice(list(data.keys()))
        text_subject = SubjectsTranslator.translate(subject)
        date = datetime.strptime(data[subject]['date'], "%d.%m.%Y")
        days = (date - datetime.now()).days
        text_time = str(days)

    await message.answer(
        'Здоров, решал сегодня варианты? \n'
        f'До ЕГЭ по {text_subject} осталось {text_time} дней!'
        )

